package com.sgcc.isc.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sgcc.common.log.annotation.Log;
import com.sgcc.common.log.enums.BusinessType;
import com.sgcc.common.security.annotation.PreAuthorize;
import com.sgcc.isc.domain.SpPortLog;
import com.sgcc.isc.service.ISpPortLogService;
import com.sgcc.common.core.web.controller.BaseController;
import com.sgcc.common.core.web.domain.AjaxResult;
import com.sgcc.common.core.utils.poi.ExcelUtil;
import com.sgcc.common.core.web.page.TableDataInfo;

/**
 * 接口日志Controller
 * 
 * @author sgcc
 * @date 2021-04-27
 */
@RestController
@RequestMapping("/SpPortLog")
public class SpPortLogController extends BaseController
{
    @Autowired
    private ISpPortLogService spPortLogService;

    /**
     * 查询接口日志列表
     */
    //@PreAuthorize(hasPermi = "isc:SpPortLog:list")
    @GetMapping("/list")
    public TableDataInfo list(SpPortLog spPortLog)
    {
        startPage();
        List<SpPortLog> list = spPortLogService.selectSpPortLogList(spPortLog);
        return getDataTable(list);
    }

    /**
     * 导出接口日志列表
     */
    //@PreAuthorize(hasPermi = "isc:SpPortLog:export")
    @Log(title = "接口日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SpPortLog spPortLog) throws IOException
    {
        List<SpPortLog> list = spPortLogService.selectSpPortLogList(spPortLog);
        ExcelUtil<SpPortLog> util = new ExcelUtil<SpPortLog>(SpPortLog.class);
        util.exportExcel(response, list, "SpPortLog");
    }

    /**
     * 获取接口日志详细信息
     */
    //@PreAuthorize(hasPermi = "isc:SpPortLog:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(spPortLogService.selectSpPortLogById(id));
    }

    /**
     * 新增接口日志
     */
    //@PreAuthorize(hasPermi = "isc:SpPortLog:add")
    @Log(title = "接口日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SpPortLog spPortLog)
    {
        return toAjax(spPortLogService.insertSpPortLog(spPortLog));
    }

    /**
     * 修改接口日志
     */
    //@PreAuthorize(hasPermi = "isc:SpPortLog:edit")
    @Log(title = "接口日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SpPortLog spPortLog)
    {
        return toAjax(spPortLogService.updateSpPortLog(spPortLog));
    }

    /**
     * 删除接口日志
     */
    //@PreAuthorize(hasPermi = "isc:SpPortLog:remove")
    @Log(title = "接口日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(spPortLogService.deleteSpPortLogByIds(ids));
    }
}
